#pragma once
#ifndef PRIVATE_STRUCT
#define PRIVATE_STRUCT

#include <map>
#include <vector>
#include <stdint.h>

typedef struct FrameHead {
    uint32_t frame_head_syn;//帧识别码

    uint16_t frame_type; //视频00  点迹01
    uint16_t frame_length;

    uint8_t azimuth_start;//方位起始
    uint8_t azimuth_stop;//方位结束
    uint16_t sector_count;//扇区个数

    uint8_t package_number;//每帧udp包编号
    uint8_t package_count;//每帧udp包数
    uint16_t frame_number;//扇区个数

    uint16_t trace_counts;//点迹个数
    uint16_t sector_number;//扇区编号

    uint32_t prf;//重频
    uint32_t cpi_count;//积累点数
    uint32_t f0;//射频频点
    uint32_t update_rate;//点迹更新率㼣������
    uint32_t azimuth_code;//方位码
    uint32_t reserved2;
    uint32_t reserved3;
}FrameHead;

const int STATE_DEMENSION = 6;
const int DOPPLER_DEMENSION = 2;
const float pi = 3.14159265358f;


//关联的数据类型
typedef struct associated_struct
{
    uint32_t track_id;
    uint32_t associated_count;
    uint32_t point_id[20];
}associated_struct;

typedef enum
{
    ACTIVE_TRACK,
    DETECTIVE_TRACK,
    DETECTIVE_POINT,
    EXPIRED_TRACK,
    EXPIRED_POINT,
    UNKNOWN,
} Elem_State;

typedef enum
{
    WITH_ACTIVE_TRACK,
    WITH_ACTIVE_TRACK_JIDONG,
    WITH_DETECTIVE_TRACK,
    WITH_POINT,
    NONE,
}corre_state;

//程序存储输入点迹
typedef struct PointInfo
{
    uint32_t point_seq;
    float pos_x;                //距离x
    float pos_y;                //距离y
    float pos_z;                //距离z

    float vel_x;
    float vel_y;
    float vel_z;
    int doppler;           //多普勒
    float velocity;             //速度

    float amplitude;            //幅度
    float SNR;                  //信噪比
    float pitch_angle;       //俯仰角
    float azi_angle;
    float noise;                //噪声均值

    corre_state correState;
    uint32_t CPISeq;

    Elem_State state;
    bool isUpdated;
    uint32_t associate_count;
    uint32_t livetime;
    uint32_t deletion_count;
    uint32_t deletion_threshold;
    float distance_increament;

    /*float distance_increament;*/
    short year;
    short month;
    short day;
    short hour;
    short minute;
    short second;

    int biaozhi;
    float r;


#if 0
    bool  isPointofSecondaryRadar;    //二次雷达
	bool  isPointofInterrogator;      //询问机
#endif
}PointInfo;

//程序存储暂态点迹
typedef struct PointTemp
{
    uint32_t point_seq;
    float pos_x;                //距离x
    float pos_y;                //距离y
    float pos_z;                //距离z

    float vel_x;
    float vel_y;
    float vel_z;
    int doppler;           //多普勒
    float velocity;             //速度

    float amplitude;            //幅度
    float SNR;                  //信噪比
    float pitch_angle;       //俯仰角
    float azi_angle;
    float noise;                //噪声均值

    Elem_State state;
    bool isUpdated;
    uint32_t associate_count;

    uint32_t three_circle_jishu;

    uint32_t CPISeq;
    uint32_t livetime;
    float distance_increament;
    short year;
    short month;
    short day;
    short hour;
    short minute;
    short second;

    int biaozhi;
    float r;

#if 0
    bool  isPointofSecondaryRadar;    //二次雷达
	bool  isPointofInterrogator;      //询问机
#endif
}PointTemp;


typedef struct TargetInfo
{
    int FrameSeq;
    int TargetCount;
    int SectorSeq;
    std::vector<PointInfo> buffer;
}TargetInfo;

typedef struct
{
    uint32_t track_seq;
    Elem_State track_state;
    uint32_t dotbianhao;
    float predicted[STATE_DEMENSION];
    float filtered[STATE_DEMENSION];
    float doppler_predicted[DOPPLER_DEMENSION];
    float doppler_filtered[DOPPLER_DEMENSION];
    float filtered_error_matrix[STATE_DEMENSION * STATE_DEMENSION];
    float doppler_filtered_error_matrix[DOPPLER_DEMENSION * DOPPLER_DEMENSION];
    float accumulation[3];

    int start_count;
    int start_threshold;
    int deletion_count;
    int deletion_threshold;

    int dopp_0;
    float range_0;
    bool out_flag = 0;
    bool dotbianhao_flag = 0;

    bool isUpdated;
    uint32_t updated_count;
    uint32_t unupdated_count;
    float SNR;
    float noise;
//    float pos_z;
    float velocity;
    float distance_increament;
    float pitchAngle;
    float azi_angle;
    bool isManeuverable;
    short year;
    short month;
    short day;
    short hour;
    short minute;
    short second;
#if 0
    bool  isPointofSecondaryRadar;    //二次雷达
	bool  isPointofInterrogator;      //询问机
#endif
    uint32_t CPISeq;
    float last_angle;
    bool budianflag;

    int biaozhi;

}TrackInfo;

typedef struct
{
    int Track_ID;
    float Track_Range;                  //距离x （滤波值）
    float Track_Azimuth;                //方位 （滤波值）
    float Track_Height;					//高度z （滤波值）
    float Track_Velocity;               //速度m/s  0.1
    float pitchAngle;

    int point_type;						//补点：0  实点：1
    int unupdated_cnt;
    int updated_cnt;

    int track_deletion_threshold;
    int track_type;						//暂定：0 稳定：1
    float SNR;
    short year;
    short month;
    short day;
    short hour;
    short minute;
    short second;
    int active_id;

    uint32_t point_seq;
    float last_angle;
    int deletion_count;
    int dotbianhao;
    float noise;


}TrackOut;
//程序存储十圈输入点迹
typedef struct PointClus
{
    short range;
    float azimuth;
    bool isCluster;
    int mcpiseq;

}PointClus;

typedef struct ClusRange
{
    float range_left;
    float range_right;
    float azimuth_left;
    float azimuth_right;

}ClusRange;

typedef struct KalmanFilterParameter
{
    float F[6 * 6];
    float Q[6 * 6];
    float Q1[6 * 6];
    float H[3 * 6];
    float R[3 * 3];
    float F_v[2 * 2];
    float Q_v[2 * 2];
    float B[3 * 6];
    float measurement_noise_var;
}KalmanFilterParameter;

typedef struct filterChangedParams
{
    float param_Q;
    float Error_R;
    float Error_azimuth;
    float acc_x;
    float acc_y;
    float acc_z;
    float azimuth_ref;
    float range_ref;
    int active_id;
}filterChangedParams;




#endif

